package com.ruoyi.inventory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.inventory.mapper.ProductStructDetailMapper;
import com.ruoyi.inventory.domain.ProductStructDetail;
import com.ruoyi.inventory.service.IProductStructDetailService;

/**
 * 产品结构清单-详情Service业务层处理
 * 
 * @author xwj
 * @date 2024-08-09
 */
@Service
public class ProductStructDetailServiceImpl extends ServiceImpl<ProductStructDetailMapper, ProductStructDetail> implements IProductStructDetailService {
    @Autowired
    private ProductStructDetailMapper productStructDetailMapper;

    /**
     * 查询产品结构清单-详情
     * 
     * @param id 产品结构清单-详情主键
     * @return 产品结构清单-详情
     */
    @Override
    public ProductStructDetail selectProductStructDetailById(Long id) {
        return productStructDetailMapper.selectProductStructDetailById(id);
    }

    /**
     * 查询产品结构清单-详情列表
     * 
     * @param productStructDetail 产品结构清单-详情
     * @return 产品结构清单-详情
     */
    @Override
    public List<ProductStructDetail> selectProductStructDetailList(ProductStructDetail productStructDetail) {
        return productStructDetailMapper.selectProductStructDetailList(productStructDetail);
    }

    /**
     * 新增产品结构清单-详情
     * 
     * @param productStructDetail 产品结构清单-详情
     * @return 结果
     */
    @Override
    public ProductStructDetail insertProductStructDetail(ProductStructDetail productStructDetail) {

      //  productStructDetailMapper.insertProductStructDetail(productStructDetail);
    save(productStructDetail);
    return productStructDetail;
    }

    /**
     * 修改产品结构清单-详情
     * 
     * @param productStructDetail 产品结构清单-详情
     * @return 结果
     */
    @Override
    public ProductStructDetail updateProductStructDetail(ProductStructDetail productStructDetail) {

      //  productStructDetailMapper.updateProductStructDetail(productStructDetail);
        updateById(productStructDetail);
        return productStructDetail;
    }

    /**
     * 批量删除产品结构清单-详情
     * 
     * @param ids 需要删除的产品结构清单-详情主键
     * @return 结果
     */
    @Override
    public int deleteProductStructDetailByIds(Long[] ids) {
        return productStructDetailMapper.deleteProductStructDetailByIds(ids);
    }

    /**
    * 条件删除
    * @param productStructDetail 产品结构清单-详情
    * @return
    */
    @Override
    public int delete(ProductStructDetail productStructDetail) {
        QueryWrapper<ProductStructDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, productStructDetail);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param productStructDetail 产品结构清单-详情
     * @return
     */
    @Override
    public Pages<ProductStructDetail> queryPage(ProductStructDetail productStructDetail) {
        QueryWrapper<ProductStructDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, productStructDetail);
        IPage<ProductStructDetail> ipage = new Query<ProductStructDetail>().getPage(productStructDetail);

        IPage<ProductStructDetail> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    /**
     * 删除产品结构清单-详情信息
     * 
     * @param id 产品结构清单-详情主键
     * @return 结果
     */
    @Override
    public int deleteProductStructDetailById(Long id) {
        return productStructDetailMapper.deleteProductStructDetailById(id);
    }
}
